"""
__project__ = '乐搏官网页面源码'
__file_name__ = 'sms'
__author__ = 'wang'
__time__ = '2021/4/12 11:07'
__product_name = PyCharm
# code is far away from bugs with the god animal protecting
    I love animals. They taste delicious.
              ┏┓      ┏┓
            ┏┛┻━━━┛┻┓
            ┃        ┃
            ┃  ┳┛  ┗┳  ┃
            ┃      ┻      ┃
            ┗━┓      ┏━┛
                ┃      ┗━━━┓
                ┃  神兽保佑    ┣┓
                ┃　永无BUG！   ┏┛
                ┗┓┓┏━┳┓┏┛
                  ┃┫┫  ┃┫┫
                  ┗┻┛  ┗┻┛
"""
import urllib.request as urllib2
import urllib.parse
import time

#
# host = "106.ihuyi.com"
# sms_send_uri = "/webservice/sms.php?method=Submit"
#
# 查看用户名 登录用户中心->验证码通知短信>产品总览->API接口信息->APIID
account = "C45332278"
# 查看密码 登录用户中心->验证码通知短信>产品总览->API接口信息->APIKEY
password = "5ec683e38c89ed47a91919cb411d02c2"
# 发送短信
# mobile = "17610768177"
text = "您的验证码是：121254。请不要把验证码泄露给其他人。"


def Submit(mobile):
    data = {'account': account, 'password': password, 'content': text, 'mobile': mobile, 'format': 'json'}
    req = urllib2.urlopen(
        url='http://106.ihuyi.com/webservice/sms.php?method=Submit',
        data=urllib.parse.urlencode(data).encode(encoding='utf-8')
    )
    content = req.read()
    return content.decode('utf-8')


# Submit(17610768177)


# 查看余额
# def GetNum():
#     data = {'account': account, 'password': password, 'format': 'json'}
#     req = urllib2.urlopen(
#         url='http://106.ihuyi.com/webservice/sms.php?method=GetNum',
#         data=urllib.parse.urlencode(data).encode(encoding='utf-8')
#     )
#     content = req.read()
#     return content.decode('utf-8')
#
# print(GetNum())

# print(time.time())

# 提交模板
content = '您的验证码是:【变量】。请不要把验证码泄露给其他人。'
data = {'account': account, 'password': password, 'format': 'json', 'content': content}
req = urllib2.urlopen(
    url='http://106.ihuyi.com/webservice/sms.php?method=AddTemplate',
    data=urllib.parse.urlencode(data).encode(encoding='utf-8')
)
content = req.read()
print(content.decode('utf-8'))

# import requests
# class BAIDU(object):
#     def baidu(self):
#         r = requests.get(url='https://www.baidu.com')
#         return r.status_code
#
# b = BAIDU()
# print(b.baidu())
